widget: Drop the ::size-allocate signal
authorMatthias Clasen <mclasen@redhat.com>
Wed, 6 May 2020 03:12:20 +0000 (23:12 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 6 May 2020 18:27:45 +0000 (14:27 -0400)
This signal is mainly used for bad things, and we
don't want to emit signals during layout if we can
avoid it.

If you are subclassing, you should either use a
layout manager or override the size_allocate vfunc.

If you are using a GtkDrawingArea or GtkGLArea,
use their ::resize signals to learn about size
changes.

Fixes: #2705
gtk/gtkwidget.c

index f873f2b4ffebaab73791b23406c45afaffc61eb2..b6beceb8bc99cbb633d09a09c9c07b9c8522815e 100644 (file)
@@ -1485,28 +1485,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                   NULL,
                  G_TYPE_NONE, 0);
 
-  /**
-   * GtkWidget::size-allocate:
-   * @widget: the object which received the signal.
-   * @width: the content width of the widget
-   * @height: the content height of the widget
-   * @baseline: the baseline
-   */
-  widget_signals[SIZE_ALLOCATE] =
-    g_signal_new (I_("size-allocate"),
-                 G_TYPE_FROM_CLASS (gobject_class),
-                 G_SIGNAL_RUN_FIRST,
-                 G_STRUCT_OFFSET (GtkWidgetClass, size_allocate),
-                 NULL, NULL,
-                  _gtk_marshal_VOID__INT_INT_INT,
-                 G_TYPE_NONE, 3,
-                  G_TYPE_INT,
-                  G_TYPE_INT,
-                  G_TYPE_INT);
-  g_signal_set_va_marshaller (widget_signals[SIZE_ALLOCATE],
-                              G_TYPE_FROM_CLASS (gobject_class),
-                              _gtk_marshal_VOID__INT_INT_INTv);
-
   /**
    * GtkWidget::state-flags-changed:
    * @widget: the object which received the signal.
@@ -4095,16 +4073,10 @@ gtk_widget_allocate (GtkWidget    *widget,
     }
   else
     {
-      if (g_signal_has_handler_pending (widget, widget_signals[SIZE_ALLOCATE], 0, FALSE))
-        g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0,
-                       priv->width,
-                       priv->height,
-                       baseline);
-      else
-        GTK_WIDGET_GET_CLASS (widget)->size_allocate (widget,
-                                                      priv->width,
-                                                      priv->height,
-                                                      baseline);
+      GTK_WIDGET_GET_CLASS (widget)->size_allocate (widget,
+                                                    priv->width,
+                                                    priv->height,
+                                                    baseline);
     }
 
   /* Size allocation is god... after consulting god, no further requests or allocations are needed */